package rensoft.android.presenter;

import static rensoft.java.lang.Lang.no;

import rensoft.android.view.ImageViewBitmapDownloaderTask;
import rensoft.android.view.ViewBase;


import android.net.Uri;
import android.widget.ImageView;

public class ImageViewPresenter extends ViewBase {

  private final ImageView imageView;

  public ImageViewPresenter(ImageView imageView, String path) {
    super(imageView);
    this.imageView = imageView;
    load(path);
  }

  private void load(String path) {
    if (no(path)) return;
    if (path.startsWith("http"))
      new ImageViewBitmapDownloaderTask(imageView, path).execute();
    else imageView.setImageURI(Uri.parse(path));
  }

}
